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ulOoXJd3wZ8m10aNb990g
GYJKHXD9991Ab9LwzHtc3eEb5T9lXnUEgjbR3HMyCsQjclpM/CqzxVGLnrDjIGt/
GigGjpq9dQKBgDG6KQn3+nB7Q3w/094JPS6fMcOZf6TK0S68yyfLrPPfQc6CuaVt
s04pK8Z1izTvrS9IKR/T9nhFETywK5y66hpXbMAh96X6lc9QD0w340gM5gs/KXxB
H/tmPsQQ5Dzx//7cYeFpU9JgqdSwSoc38Kw0avSGB2kCNwUcjUda7eqZAoGBALl4
Vl08oOc7KRtYc/4E5Eu9cmHGcpySMIsKsr/X7gHyYqaDRsf2FxskxWx08pnWwyWl
JdmIOiNHBwqm7j4CcyDCUqP+6oHUB3dLM/KQXwjxxnSKpCg0WWotIUN6+4+v6Lip
xf8rKdIFILOCOpT3DuJf/XEyN/Bw2KsR94V5tvwdAoGBAMtnfiwWXiZkS07lYAI4
KY2M1I41RcmXVgyK2v2F0mfpJ5y1Vay07S32uwEZjGrjXaoqjQ1sTFJHz4XeGyCg
yWDgq4Z3ARhbf2mNVdnDbR1VGMNaD19YnB4qWMKTNM6vVE+X5b8E3a04F9w0jccd
1zphHskiy9sQAPiJxNTH/ZJ3
-----END PRIVATE KEY-----
';
    if( $_POST){
        
        include 'request.php';
        
        $url = '192.168.33.10/merchant/process.php';

        $_POST['method'] = 'reqGetBankAccount';
        //加密
        $res = openssl_pkey_get_private($privkey);
        $ssl_sign = '';

        if (openssl_sign(md5(json_encode($_POST)), $ssl_sign, $res)){
            $ssl_sign = base64_encode($ssl_sign);
        }
        $_POST['ssl_sign'] = $ssl_sign;
        
        $res2 = sendRequest($url, $_POST);
        
        $res2 = json_decode($res2, 1);
        
        $res = json_decode($res2,1);
        
        if( $res['code'] == 1 ){
            $desc = '请求成功.';
        }elseif( $res['code'] == 2 ){
            $desc = '商户不存在.';
        }elseif( $res['code'] == 3 ){
            $desc = '有参数无效.';
        }elseif( $res['code'] == 4 ){
            $desc = 'Sign验证失败.';
        }elseif( $res['code'] == 5 ){
            $desc = 'TransId已存在.';
        }elseif( $res['code'] == 6 ){
            $desc = '单次交易金额未达要求.';
        }elseif( $res['code'] == 7 ){
            $desc = '总交易金额未达要求.';
        }elseif( $res['code'] == 8 ){
            $desc = '网络错误.';
        }elseif( $res['code'] == 9 ){
            $desc = '交易不存在.';
        }elseif( $res['code'] == 10 ){
            $desc = '银行账户不存在.';
        }elseif( $res['code'] == 11 ){
            $desc = '验证未通过.';
        }
   
 
                $return[$i]['code'] = '001';
                $return[$i]['bank_name'] = $row[0];
                $return[$i]['bank_code'] = $row[5];
                $return[$i]['account'] = $row[1];
                $return[$i]['account_number'] = $row[2];
                $return[$i]['address'] = $row[3];
                $return[$i]['status'] = $status;
     
        
        echo '<h1>';
        echo '返回值：'.'_'.$desc;
        echo '</h1>';
        
        if(is_array($res2['data'])){
            foreach ($res2['data'] as $key => $value) {
                
                echo $key.'.  bank_name: '.$value['bank_name'].'<br>';
                echo '  bank_code: '.$value['bank_code'].'<br>';
                echo '  account: '.$value['account'].'<br>';
                echo '  account_number: '.$value['account_number'].'<br>';
                echo '  address: '.$value['address'].'<br>';
                echo '  status: '.$value['status'].'<br><br><br>';
            }
        }
        
    }
   

?>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style>
        tr{margin-bottom: 15px;}
        tr td:first-child{text-align: right;padding-right: 10px;font-weight: bold}
        form  input:not(.submit){height:30px;width:200px;}
        .readonly{border:1px solid #ccc;color:#888;}
        em{font-size: 14px;}
    </style>
</head>

<h5><a href="index.html">Back home</a></h5>
<h3>Fund In.</h3>
<hr>

<form action="" method="post">
<table CellSpacing=10>
   <tr><td>merchantId:</td>         <td><input type="text" name="merchantId"value="MDP54c2121a687c8"  > 
   

   
   <tr><td>SUBMIT:</td>             <td><input type="submit" value="GO"  class="submit" >
</table>
</form>